/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "accountspayable")						
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Accountspayable.findAll", query = "SELECT a FROM Accountspayable a"),
    @NamedQuery(name = "Accountspayable.findByAccountsPayableId", query = "SELECT a FROM Accountspayable a WHERE a.accountsPayableId = :accountsPayableId"),
    @NamedQuery(name = "Accountspayable.findByProviderId", query = "SELECT a FROM Accountspayable a WHERE a.providerId.providerId = :providerId"),
    @NamedQuery(name = "Accountspayable.findByDate", query = "SELECT a FROM Accountspayable a WHERE a.date = :date"),
    @NamedQuery(name = "Accountspayable.findByAmount", query = "SELECT a FROM Accountspayable a WHERE a.amount = :amount"),
    @NamedQuery(name = "Accountspayable.findByRemark", query = "SELECT a FROM Accountspayable a WHERE a.remark = :remark"),
    @NamedQuery(name = "Accountspayable.findByActive", query = "SELECT a FROM Accountspayable a WHERE a.active = :active")})
public class Accountspayable implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)
    @Column(name = "accountsPayableId")
    */
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer accountsPayableId;
    @Basic(optional = false)
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "amount")
    private Float amount;
    @Column(name = "remark")
    private String remark;
    @Column(name = "active")
    private Boolean active;
    @OneToMany(mappedBy = "accountsPayableId")
    private Collection<Paymentplan> paymentplanCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accountspayable")
    private Collection<Credititempharmacy> credititempharmacyCollection;    
    @JoinColumn(name = "providerId", referencedColumnName = "providerId")
    @ManyToOne
    private Provider providerId;

    public Accountspayable() {
    }

    public Accountspayable(Integer accountsPayableId) {
        this.accountsPayableId = accountsPayableId;
    }

    public Accountspayable(Integer accountsPayableId, Date date) {
        this.accountsPayableId = accountsPayableId;
        this.date = date;
    }

    public Integer getAccountsPayableId() {
        return accountsPayableId;
    }

    public void setAccountsPayableId(Integer accountsPayableId) {
        this.accountsPayableId = accountsPayableId;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Float getAmount() {
        return amount;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    @XmlTransient
    public Collection<Paymentplan> getPaymentplanCollection() {
        return paymentplanCollection;
    }

    public void setPaymentplanCollection(Collection<Paymentplan> paymentplanCollection) {
        this.paymentplanCollection = paymentplanCollection;
    }

    @XmlTransient
    public Collection<Credititempharmacy> getCredititempharmacyCollection() {
        return credititempharmacyCollection;
    }

    public void setCredititempharmacyCollection(Collection<Credititempharmacy> credititempharmacyCollection) {
        this.credititempharmacyCollection = credititempharmacyCollection;
    }

    public Provider getProviderId() {
        return providerId;
    }

    public void setProviderId(Provider providerId) {
        this.providerId = providerId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountsPayableId != null ? accountsPayableId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accountspayable)) {
            return false;
        }
        Accountspayable other = (Accountspayable) object;
        if ((this.accountsPayableId == null && other.accountsPayableId != null) || (this.accountsPayableId != null && !this.accountsPayableId.equals(other.accountsPayableId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Accountspayable[ accountsPayableId=" + accountsPayableId + " ]";
    }
    
}
